fix: improve error messages for platform credential expiry in Semantic Layer tools#714
Conversation
|
@psaikaushik hello pls make sure to address the same baseline comments I made from your other PR - signed commits, change log issue, etc. In the meantime as well, would love to see validation / screenshots of your fixes! (before and after as this update ). That would be very helpful 🙏 |
18a49c5 to
6c4ae85
Compare
|
@jairus-m : Just created another commit fixing all of them. Sorry about that. It skipped my mind. Thanks for your help! Regarding the test, I mocked the credentials expiration Before After Please take a look. thanks! |
|
@jairus-m : Gentle reminder on the review. All the comments are addressed. Please take a look whenever you are free. thanks! |
|
Hey @psaikaushik totally, thank you for the friendly reminder. I have this PR in mind and it's absolutely in my "todo" queue. As you know, plates get full - thank you for your patience. 🙏 Pls hang tight. |
|
Hey @psaikaushik I'm trying to checkout your branch and merge the latest changes from main. There are conflicts. I'm trying to make changes but I do not think you allow maintainers to edit your branch. Can you update your branch and address the conflicts? Or allow me to push the merge to main?
|
@jairus-m : Sorry about that. Just gave permissions on the PR to be editable by the maintainers. I am also trying to rebase on my side but did that so that it's easier for you. Please take a look. thanks! |
…c Layer tools When query_metrics or execute_sql fail due to expired dbt Cloud platform credentials, the error now clearly indicates this is a platform-side issue and directs users to refresh credentials in the dbt Cloud UI, rather than suggesting local Snowflake re-authentication. Closes dbt-labs#670
f70b032 to
8c6c4ff
Compare
| _PLATFORM_CREDENTIAL_ERROR_PATTERNS: list[re.Pattern[str]] = [ | ||
| re.compile(r"SSO authentication has expired", re.IGNORECASE), | ||
| re.compile(r"re-connect to Snowflake", re.IGNORECASE), | ||
| re.compile(r"refresh.snowflake.oauth.credentials", re.IGNORECASE), | ||
| re.compile(r"authentication token has expired", re.IGNORECASE), | ||
| re.compile(r"oauth.*token.*expired", re.IGNORECASE), | ||
| re.compile(r"token.*expired.*re-?authenticate", re.IGNORECASE), | ||
| ] |
There was a problem hiding this comment.
Left a comment related to these lines in the issue. Let me know what you think! We can continue that convo there for now.


Summary
When
query_metricsorexecute_sqlfail due to expired dbt Cloud platform credentials, the error message currently points users toward local Snowflake re-authentication steps — which is misleading and sends them down the wrong troubleshooting path.This PR adds detection for platform credential expiry errors and appends a clear, actionable hint directing users to refresh their credentials in the dbt Cloud UI.
Closes #670
What Changed
src/dbt_mcp/semantic_layer/client.py_PLATFORM_CREDENTIAL_ERROR_PATTERNS— a list of compiled regex patterns that match common credential expiry messages from Snowflake/data platforms (SSO expired, OAuth token expired, etc.)_PLATFORM_CREDENTIAL_HINT— a clear, actionable message explaining this is a platform-side credential issue and directing users to dbt Cloud UI → Profile → Credentials_is_platform_credential_error()— a helper that checks an error string against all known patterns_format_semantic_layer_error()— now detects platform credential errors and appends the hint, while preserving the original error message and all existing formatting behaviortests/unit/semantic_layer/test_platform_credential_errors.py_is_platform_credential_error()— covers all known patterns, case insensitivity, and negative cases (generic errors, syntax errors, timeouts, empty strings)_format_semantic_layer_error()— verifies the hint is appended for credential errors, preserved for QueryFailedError wrappers, and not added for generic errorsWhy
Users on dbt Cloud with Snowflake SSO credentials that expire see this error:
This sends them to local re-authentication docs, which doesn't fix the problem. The actual fix is to refresh development credentials in the dbt Cloud UI. This PR makes that distinction clear.
Test plan
_format_semantic_layer_errorlogic is untouched; the hint is additiveChecklist